// 二维转一维
function fm(brr:Array<number|Array<number>>) {
    console.log(brr);
    let newbrr:Array<number>=[]
    brr.forEach((item:Array<number>|number)=>{
        if (Array.isArray(item)) {
            newbrr.push(...fm(item))
        }
        else{
            newbrr.push(item)
        }
    })
    return newbrr
}
console.log(fm([[1,2,3],[5,6,7],[9]]));

// 冒泡
function fn(arr:Array<number>) {
    console.log(arr);
    for (let i:number = 0; i < arr.length-1; i++) {
        for (let j:number = 0; j < arr.length-1-i; j++) {
          
           if (arr[j]>arr[j+1]) {
             let temp=arr[j]
             arr[j]=arr[j+1]
             arr[j+1] =temp 
           }
        }
    }
    return arr
    
}
console.log(fn([3,9,5,7,8,1]));
// 裴波那契
function fns(n:number) {
    console.log(n);
    let tem=[1,1]
    if (n===1||n===2) {
        return 1
    }
for (let i = 2; i < n; i++) {
    tem[i]=tem[i-1]+tem[i-2]
    tem.push(tem[i])
}
   tem.splice(n,1)
   return tem
}
console.log(fns(10));


